Skip to content

refactor(chat_gpt): decompose the two large handlers#607

Merged
nolik merged 1 commit into
mainfrom
iter6/decompose-handlers
Jul 18, 2026
Merged

refactor(chat_gpt): decompose the two large handlers#607
nolik merged 1 commit into
mainfrom
iter6/decompose-handlers

Conversation

@nolik

@nolik nolik commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Iteration 6/8 of the hardening plan (§4 refactors).

Splits the ~80-line handle_chat_gpt_question and ~60-line handle_reply into small, single-purpose helpers:

Helper Role Tested
bot_configuration_for_message pick profile by mention regex ✅ unit
bot_configuration_for_profile look up profile of a prior bot message ✅ unit
build_question_context summary-vs-rolling context routing via e2e
send_gpt_reply thread-aware reply send via e2e

handle_reply is also flattened from if let Ok { … } to a let Ok(..) else { return Ok(()) } guard; its send stays non-threaded to preserve exact current behavior.

Pure refactor — no happy-path behavior change (chat_gpt_e2e exercises the question path end-to-end). 3 new unit tests for the pure selectors (8 → 11). Local gate green: fmt, clippy -D warnings, unit tests, integration tests compile.

🤖 Generated with Claude Code

Splits the ~80-line handle_chat_gpt_question and ~60-line handle_reply
into small, single-purpose helpers (§4):
- `bot_configuration_for_message` / `bot_configuration_for_profile`:
  pure profile-selection functions, now covered by unit tests.
- `build_question_context`: the summary-vs-rolling context routing.
- `send_gpt_reply`: thread-aware reply send (used by the question path).

handle_reply is additionally flattened from `if let Ok { .. }` to a
`let Ok(..) else { return Ok(()) }` guard. Its send stays non-threaded
to preserve exact current behavior.

Pure refactor — no happy-path behavior change (chat_gpt_e2e is the
backstop). 3 new unit tests; local gate green (fmt, clippy -D warnings,
11 unit tests, integration tests compile).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nolik
nolik merged commit f7c138d into main Jul 18, 2026
7 checks passed
@nolik
nolik deleted the iter6/decompose-handlers branch July 18, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant